package com.purang.web.service;

import com.purang.web.converter.DoConverter;
import com.purang.web.converter.PoConverter;
import com.purang.web.entity.domain.UserDo;
import com.purang.web.entity.dto.UserDto;
import com.purang.web.entity.po.UserPo;
import com.purang.web.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class TestServiceImpl implements TestService {

    private static final DoConverter DO_CONVERTER = DoConverter.INSTANCE;

    private static final PoConverter PO_CONVERTER = PoConverter.INSTANCE;

    @Autowired
    private UserMapper userMapper;

    @Override
    public void insertUser(UserDto userDto) {
        log.info("The param userDto {}", userDto);
        UserDo userDo = DO_CONVERTER.convert(userDto);
        log.info("The param userDo {}", userDo);
        UserPo userPo = PO_CONVERTER.convert(userDo);
        log.info("The param userPO {}", userPo);
        userMapper.insert(userPo);
    }
}
